import { Component, OnInit } from '@angular/core';
import { MessageService } from 'src/app/core/service/message.service';
import { ApiService } from 'src/app/core/api';
import { NzMessageService } from 'ng-zorro-antd';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';

@Component({
    templateUrl: './index.html',
    styleUrls: ['./index.scss']
})
export class JBXXComponent implements OnInit {
    iForm: FormGroup;
    user;
    ngOnInit() {
        this.message.setBreadcrumb({
            breadcrumbs: [
                { name: '我要检测' }
            ]
        });
        this.iForm = this.fb.group({
            mobile: [null],
            wechat: [null],
            nickName: [null],
            email: [null],
            qq: [null]
        });
        this.api.post('用户详情', {}).then(res => {
            this.user = res['data']['enterpriseUserDetail'];
            localStorage.setItem('user', JSON.stringify(this.user));
            console.log(this.user)
            this.iForm.setValue({mobile:this.user.mobile,wechat:this.user.wechat,nickName:this.user.nickName,email:this.user.email,qq:this.user.qq})
        })
        // this.user = localStorage.getItem('user');

    }
    submit(data) {
        this.api.post('修改基本信息', data).then((res: any) => {
            this.msg.success('修改成功');
        }).catch((res) => {
            this.msg.error(res.message);
        });
    }
    constructor(
        private router: Router,
        private fb: FormBuilder,
        private message: MessageService,
        private msg: NzMessageService,
        private api: ApiService
    ) { }
}